package com.jsgt.greekfire.ui.mainassets.adapter

import android.content.Context
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.MainAssetsBean

class MainAssetsAdapter(
    context: Context,
    layoutId: Int,
    data: MutableList<MainAssetsBean>? = null
) : BaseQuickAdapter<MainAssetsBean, BaseViewHolder>(layoutId, data) {

    override fun convert(helper: BaseViewHolder, item: MainAssetsBean) {
        helper.setImageResource(R.id.ivLogo, item?.image!!)
            .setText(R.id.ivCurrency, item?.name)
            .setText(R.id.tvPrice, item?.amount)
            .setText(R.id.tvRmbPrice, item?.rmbrice)
        if (isShowMoney) {
            helper.setText(R.id.tvPrice, item?.amount)
                .setText(R.id.tvRmbPrice, item?.rmbrice)
        } else {
            helper.setText(R.id.tvPrice, "****")
                .setText(R.id.tvRmbPrice, "****")
        }
    }

    private var isShowMoney = true

    fun setShowMoney(showMoney: Boolean) {
        isShowMoney = showMoney
        notifyDataSetChanged()
    }
}